package com.tmp.alarm.model;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 */
public class JobModel implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5653087305954353377L;
	private long id;
	private String log_time;
	private int type;
	private String job_id;
	private String job_state;
	private String start_time;
	private String user_name;
	private String queue;
	private String priority;
	private String used_containers;
	private String rsvd_containers;
	private String used_mem;
	private String rsvd_mem;
	private String needed_mem;
	private String am_info;
	private String application_id;
	private String erp;
	private String ip;
	private String task_type;
	private String task_id;
	private String log_id;
	private String code;
	private String application_type;
	private String application_state;
	private String application_final_state;
	private String application_progress;
	private String application_tracking_url;

	final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");

	public JobModel(String line) {
		String[] infos = line.split("\t");
		if (infos.length >= 22) {
			this.log_time = infos[0].trim();
			this.job_id = infos[1].trim();
			this.job_state = infos[2].trim();
			try {
				this.start_time = sdf.format(new Date(Long.parseLong(infos[3].trim())));
			} catch (NumberFormatException e) {
				e.printStackTrace();
			}
			this.user_name = infos[4].trim();
			this.queue = infos[5].trim();
			this.priority = infos[6].trim();
			this.used_containers = infos[7].trim().equals("N/A") ? "-1" : infos[7].trim();
			this.rsvd_containers = infos[8].trim().equals("N/A") ? "-1" : infos[8].trim();
			this.used_mem = infos[9].trim().equals("N/A") ? "-1" : infos[9].trim().replace("M", "");
			this.rsvd_mem = infos[10].trim().equals("N/A") ? "-1" : infos[10].trim().replace("M", "");
			this.needed_mem = infos[11].trim().equals("N/A") ? "-1" : infos[11].trim().replace("M", "");
			this.am_info = infos[12].trim();
			this.application_id = infos[13].trim();
			String applicationName = infos[14].trim().replace("[", "").replace("]", "");
			String[] split = applicationName.split(",");
			if (split.length == 0) {
				this.erp = "";
				this.ip = "";
				this.task_type = "";
				this.task_id = "";
				this.log_id = "";
				this.code = "";
			} else if (split.length == 1) {
				this.erp = "";
				this.ip = "";
				this.task_type = "";
				this.task_id = "";
				this.log_id = "";
				this.code = split[0].trim();
			} else if (split.length == 6) {
				this.erp = split[0].trim();
				this.ip = split[1].trim();
				this.task_type = split[2].trim();
				this.task_id = split[3].trim();
				this.log_id = split[4].trim();
				this.code = split[5].trim();
			}
			this.application_type = infos[15].trim();
			this.application_state = infos[18].trim();
			this.application_final_state = infos[19].trim();
			this.application_progress = infos[20].trim().replace("%", "");
			this.application_tracking_url = infos[21].trim();
		}
	}

	public long getId() {
		return this.id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getLog_time() {
		return this.log_time;
	}

	public void setLog_time(String log_time) {
		this.log_time = log_time;
	}

	public int getType() {
		return this.type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getJob_id() {
		return this.job_id;
	}

	public void setJob_id(String job_id) {
		this.job_id = job_id;
	}

	public String getJob_state() {
		return this.job_state;
	}

	public void setJob_state(String job_state) {
		this.job_state = job_state;
	}

	public String getStart_time() {
		return this.start_time;
	}

	public void setStart_time(String start_time) {
		this.start_time = start_time;
	}

	public String getUser_name() {
		return this.user_name;
	}

	public void setUser_name(String user_name) {
		this.user_name = user_name;
	}

	public String getQueue() {
		return this.queue;
	}

	public void setQueue(String queue) {
		this.queue = queue;
	}

	public String getPriority() {
		return this.priority;
	}

	public void setPriority(String priority) {
		this.priority = priority;
	}

	public String getUsed_containers() {
		return this.used_containers;
	}

	public void setUsed_containers(String used_containers) {
		this.used_containers = used_containers;
	}

	public String getRsvd_containers() {
		return this.rsvd_containers;
	}

	public void setRsvd_containers(String rsvd_containers) {
		this.rsvd_containers = rsvd_containers;
	}

	public String getUsed_mem() {
		return this.used_mem;
	}

	public void setUsed_mem(String used_mem) {
		this.used_mem = used_mem;
	}

	public String getRsvd_mem() {
		return this.rsvd_mem;
	}

	public void setRsvd_mem(String rsvd_mem) {
		this.rsvd_mem = rsvd_mem;
	}

	public String getNeeded_mem() {
		return this.needed_mem;
	}

	public void setNeeded_mem(String needed_mem) {
		this.needed_mem = needed_mem;
	}

	public String getErp() {
		return erp;
	}

	public void setErp(String erp) {
		this.erp = erp;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getTask_type() {
		return task_type;
	}

	public void setTask_type(String task_type) {
		this.task_type = task_type;
	}

	public String getTask_id() {
		return task_id;
	}

	public void setTask_id(String task_id) {
		this.task_id = task_id;
	}

	public String getLog_id() {
		return log_id;
	}

	public void setLog_id(String log_id) {
		this.log_id = log_id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getApplication_id() {
		return this.application_id;
	}

	public void setApplication_id(String application_id) {
		this.application_id = application_id;
	}

	public String getApplication_type() {
		return this.application_type;
	}

	public void setApplication_type(String application_type) {
		this.application_type = application_type;
	}

	public String getApplication_state() {
		return this.application_state;
	}

	public void setApplication_state(String application_state) {
		this.application_state = application_state;
	}

	public String getApplication_final_state() {
		return this.application_final_state;
	}

	public void setApplication_final_state(String application_final_state) {
		this.application_final_state = application_final_state;
	}

	public String getApplication_progress() {
		return this.application_progress;
	}

	public void setApplication_progress(String application_progress) {
		this.application_progress = application_progress;
	}

	public String getApplication_tracking_url() {
		return this.application_tracking_url;
	}

	public void setApplication_tracking_url(String application_tracking_url) {
		this.application_tracking_url = application_tracking_url;
	}

	public String getAm_info() {
		return am_info;
	}

	public void setAm_info(String am_info) {
		this.am_info = am_info;
	}
	
}
